function showPopup() {
    var popup = document.getElementById("popup");

    popup.style.display = "block";

    var left = (window.innerWidth - popup.offsetWidth) / 2;
    var top = (window.innerHeight - popup.offsetHeight) / 2;

    popup.style.left = left + "px";
    popup.style.top = top + "px";

    var shadowEl = document.createElement("div");
    shadowEl.id = "shadow";

    document.getElementsByTagName("body")[0].appendChild(shadowEl);
}

function closePopup() {
    var popup = document.getElementById("popup");
    var shadow = document.getElementById("shadow");

    popup.style.display = "none";
    (shadow.parentNode).removeChild(shadow);
}

function addEvents() {
    document.getElementsByClassName("order")[0].addEventListener("click", showPopup, false);
    document.getElementsByClassName("close")[0].addEventListener("click", closePopup, false);
}

document.addEventListener("DOMContentLoaded", function() {
    addEvents();
}, false);

